<?php 

//请求数据库
$db = require 'db.php';
//将$_POST赋值到$db[];

date_default_timezone_set('prc');
$_POST['time']=date('Y/m/d h:i:s',time());

$db[]=$_POST;
//转换成字符串形式

//添加搜索


$d = "<?php  \n  return    " .var_export($db,true). ";?>";

if(file_put_contents('db.php',$d)){
	$n = count($db);
	$result = array(
		//发表后的状态
		'state'=> 'success',
		'message'=> '发表成功',
		'count'=>$n,
		'data'=>$_POST
		
		);
	
	echo json_encode($result);
}else{
	$result = array(

		'state'=> 'error',
		'message'=> '发表失败'

		);
	echo json_encode($result);

}